<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns="http://www.w3.org/1999/xhtml"
                template="./tpl/panel.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <ui:define name="title">
        Добавление операции
    </ui:define>

   
    <ui:define name="panel">
        <h1>Добавление операции</h1>
        <div class="well">
            <f:view>
                <h:form enctype="multipart/form-data">
                    
                              
                <table class="table table-responsive">
                    <tr>
                        <td>
                            Имя:
                        </td>
                        <td>
                            <h:inputText class="form-control" value ="#{addTransactionView.name}" required="true"></h:inputText>                        </td>
                    </tr>
                    <tr>
                        <td>
                            Сумма:
                        </td>
                        <td>
                            <h:inputText class="form-control" value ="#{addTransactionView.amount}" required="true"></h:inputText>                        </td>
                    </tr>
                    
                    <tr>
                        <td>
                            Cчёт:
                        </td>
                        <td>
                            <h:selectOneListbox value="#{addTransactionView.account}">
                                <c:if test="#{addTransactionView.accounts.size()==0}">
                                    <f:selectItem itemLabel="Список счетов пуст"></f:selectItem>
                                </c:if>
                                <c:forEach items="#{addTransactionView.accounts}" var="item"> 
                                    <f:selectItem  itemLabel="#{item.name}" itemValue="#{item.id}"/>
                                </c:forEach>
                            </h:selectOneListbox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Тип:
                        </td>
                        <td>
                            <h:selectOneListbox value="#{addTransactionView.type}">
                                <c:if test="#{addTransactionView.transactionType.size()==0}">
                                    <f:selectItem itemLabel="Список типов пуст"></f:selectItem>
                                </c:if>
                                <c:forEach items="#{addTransactionView.transactionType}" var="item"> 
                                    <f:selectItem  itemLabel="#{item.name}" itemValue="#{item.id}"/>
                                  </c:forEach>
                            </h:selectOneListbox>
                        </td>
                    </tr>
                    
                    <tr>
                        <td>
                            Отправить:
                        </td>
                        <td>
                            <h:commandButton action="#{addTransactionView.postTransaction()}"  class="btn btn-success" value="Отправить"></h:commandButton>
                        </td>
                    </tr>
                </table>
            </h:form>
            </f:view>
        </div>
    </ui:define>

</ui:composition>
